package org.message.util
{
	import mx.controls.dataGridClasses.DataGridColumn;
	import mx.core.ClassFactory;
	import mx.formatters.DateFormatter;
	
	import org.message.MessageManager;
	import org.message.entity.Count;
	import org.tools.ui.renderer.grid.DateFormateRenderer;
	import org.tools.ui.renderer.grid.StateRenderer;
	
	public class Utils
	{
		public static var USERID:String = null;
		public static var MANAGER:MessageManager = null;
		
		public static const COM:String = "common";
		public static const SYS:String = "system";
		public static const COUNT_PAGE:String = "countPage";
		public static const LIST:String = "list";
		
		public static const count:Count = new Count();
		
		public static const DATE_FORMATTER:DateFormatter = new DateFormatter();
		
		public static function dateDataGridColumn(field:String, columnName:String, width:int, formaterString:String='YYYY-MM-DD HH:NN'):DataGridColumn
		{
			var column:DataGridColumn = new DataGridColumn(columnName);
			var renderer:ClassFactory = new ClassFactory(DateFormateRenderer);
			
			renderer.properties = {'field':field, 'formateStr':formaterString};
			column.itemRenderer = renderer;
			column.width = width;
			
			return column;
		}

		public static function stateDataGridColumn(field:String, columnName:String, width:int):DataGridColumn
		{
			var column:DataGridColumn = new DataGridColumn(columnName);
			var renderer:ClassFactory = new ClassFactory(StateRenderer);
			
			renderer.properties = {'field':field};
			column.itemRenderer = renderer;
			column.width = width;
			
			return column;
		}
		
		public static function commonDataGridColumn(field:String, columnName:String, width:int):DataGridColumn
		{
			var column:DataGridColumn = new DataGridColumn(columnName);
			
			column.dataField = field;
			column.width = width;
			
			return column;
		}
	}
}